<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ attribute name="name" type="java.lang.String" required="true" description="文件输入框名称"%>
<%@ attribute name="ext" type="java.lang.String" required="false" description="上传文件格式"%>
<%@ attribute name="label" type="java.lang.String" required="false" description="显示名称"%>
<%@ attribute name="value" type="java.lang.String" required="false" description="文件路径"%>
<img src="${value }" id="${name }_img" style="width:160px;height:140px;display:${value=="" ? "none":"default"}"/>
<input id="${name }_id" name="${name }_name" type="file"  class="file-loading">
<input type="hidden" type="hidden" id="${name }" name="${name }" value="${value }"/>
<script type="text/javascript">
$(document).on('ready', function() {
$("#${name }_id").fileinput({
	showCaption: false,
	language:'zh',
	showDrag:false,
	overwriteInitial: true,
	initialPreviewAsData: true,
	maxFileCount:1,
	showPreview:false,
	uploadUrl: "${ctx}/fileinput", // server upload action
    uploadAsync: true
	});
 $("#${name}_id").on("fileuploaded",function(e,d,p,id)
		 {
	 		$("#${name}").val(d.response.data);
	 		$("#${name}_img").attr("src",d.response.data).show();
	 });
});
</script>